<?php				
/*
*  index  *
*/
	echo "index.thtml\n";
	$igen = "";
	$igen .= pr("<?php");
	$igen .= pr("\techo \"<h2 id='contentTitle'>\".\$pageTitle.\"</h2>\";");
	$igen .= pr("\techo \$this->renderElement('message');");
	$igen .= pr("");
	$igen .= pr("\techo \$html->link('Cadastrar ".$strDS."', '/".$strDP."/add/');");
	$igen .= pr("\techo \"<br /><br />\";");
	$igen .= pr("");
	$igen .= pr("\tif (isset(\$".$strDP.") && is_array(\$".$strDP.") && (!empty(\$".$strDP."))) {");
	$igen .= pr("\t\techo \"<table>\";");
	/* titulo da tabela */
			$igen .= pr("\t\techo \"<tr class='sort'>\";");
	foreach ($column as $c) {
		if (substr($c,-3,3) == "_id") {
			$col_name = substr($c,0,strlen($c)-3);
			$col_name = ucfirst($col_name);
		} else {
			$col_name = ucfirst($c);
		}
		
		$igen .= pr("\t\t\techo \"<th>".$col_name."</th>\";");
	}
	$igen .= pr("\t\t\techo \"<th>Editar</th>\";");
	$igen .= pr("\t\t\techo \"<th>Excluir</th>\";");
	$igen .= pr("\t\techo \"</tr>\";");
	$igen .= pr("");
	/* linha das tabelas */
			$igen .= pr("\t\t\$i=0;");
	$igen .= pr("\t\tforeach (\$".$strDP." as \$".$strDS.") {");
	$igen .= pr("\t\t\tif ((\$i++ % 2) == 1) \$zebrado = \" class='oddTr' \";");
	$igen .= pr("\t\t\telse \$zebrado = \"\";");
	$igen .= pr("\t\t\techo \"<tr \".\$zebrado.\">\";");
	foreach ($column as $c) {
		if ($c == "id" || $c == "nome") {
			$igen .= pr("\t\t\techo \"<td>\".\$html->link(\$".$strDS."['".$strUS."']['".$c."'],'/".$strDP."/view/'.\$".$strDS."['".$strUS."']['id']).\"</td>\";");
		} else if (substr($c,-3,3) == "_id"){
			$c =  substr($c,0,strlen($c)-3);
			$igen .= pr("\t\t\techo \"<td>\".\$html->link(\$".$strDS."['".ucfirst($c)."']['nome'],'/".plural($c)."/view/'.\$".$strDS."['".ucfirst($c)."']['id']).\"</td>\";");
		} else {
			$igen .= pr("\t\t\techo \"<td>\".\$".$strDS."['".$strUS."']['".$c."'].\"</td>\";");
		}
	}
	$igen .= pr("\t\t\techo \"<td>\".html_entity_decode(\$html->link(\$html->image('fileedit.png',array('class'=>'opIcon')), '/".$strDP."/edit/'.\$".$strDS."['".$strUS."']['id'])).\"</td>\";");
	$igen .= pr("\t\t\techo \"<td>\".html_entity_decode(\$html->link(\$html->image('filedel.png',array('class'=>'opIcon')), '/".$strDP."/delete/'.\$".$strDS."['".$strUS."']['id'], array(), 'Confirma a exclusão deste item?')).\"</td>\";");
			
	$igen .= pr("\t\t\techo \"</tr>\";");
	$igen .= pr("\t\t}");
	$igen .= pr("\t\techo \"<tr id='footerTable'><td colspan='100%'></td></tr>\";");
	$igen .= pr("\t\techo \"</table>\";");
	$igen .= pr("\t}");
	$igen .= pr("?>");
	echo $igen;

?>